package com.ixiaowo.springcouldeureka;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;

public class PreZullFilter extends ZuulFilter {
    private static final Logger LOGGEg = LoggerFactory.getLogger(PreZullFilter.class);
//filter的类型
    @Override
    public String filterType() {
        return "pre";
    }
//执行的顺序 数字越大越靠后
    @Override
    public int filterOrder() {
        return 1;
    }
//执行的filter  false就不执行这个filter了
    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() {
        HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
        String remoteHost = request.getRemoteHost();
        LOGGEg.info("请求的host"+remoteHost);
        return null;
    }
}
